import React, { useState, useEffect } from 'react';
import { Layout, Menu, Breadcrumb , Col, Row, Button, Avatar, Popconfirm, message} from 'antd';



import { BrowserHistory, Router, Route, Link, Redirect, Switch,useHistory } from 'react-router-dom'
//入院管理
import BingRenRuYuanXinXi from '../../components/ZhuYuan/RuYuanGuanLi/BingRenRuYuanXinXi';
import PersonInfo from '../../components/ZhuYuan/RuYuanGuanLi/PersonInfo';
import XinZengBingRen from '../../components/ZhuYuan/RuYuanGuanLi/XinZengBingRen';
//病房管理
import BingFangXinXi from '../../components/ZhuYuan/BingFangGuanLi/BingFangXinXi';
import BingChuangXinXi from '../../components/ZhuYuan/BingFangGuanLi/BingChuangXinXi/BingChuangXinXi'
import XiuGaiBingChuang from '../../components/ZhuYuan/BingFangGuanLi/XiuGaiBingChuang/XiuGaiBingChuang'
import XiuGaiYiZhu from '../../components/ZhuYuan/BingFangGuanLi/XiuGaiYiZhu/XiuGaiYiZhu'
//出院管理
import ChuYuanBingRenXinXi from '../../components/ZhuYuan/ChuYuanGuanLi/ChuYuanBingRenXinXi';
import Chuyuanbingrenbingli from '../../components/ZhuYuan/ChuYuanGuanLi/Chuyuanbingrenbingli';
import ChuyuanJinemingxi from '../../components/ZhuYuan/ChuYuanGuanLi/ChuyuanJinemingxi';
//在院计费
import KeMuBianMaBiao from '../../components/ZhuYuan/ZaiYuanJiFei/KeMuBianMaBiao';
import GeRenFeiYong from '../../components/ZhuYuan/ZaiYuanJiFei/GeRenFeiYong';
import JiaoFeiGuanLi from '../../components/ZhuYuan/ZaiYuanJiFei/JiaoFeiGuanLi';
import ShouFeiBiaoZhun from '../../components/ZhuYuan/ZaiYuanJiFei/ShouFeiBiaoZhun';
import ZhuYuanBuShouRu from '../../components/ZhuYuan/ZaiYuanJiFei/ZhuYuanBuShouRu';
//如愿系统维护管理
import KeMuBianMaBiaoWeiHu from "../../components/ZhuYuan/XiTongWeiHu/KeMuBianMaBiaoWeiHu";
import QingLiGuoQiShuJu from "../../components/ZhuYuan/XiTongWeiHu/QingLiGuoQiShuJu";
import ShouFeiBiaoZhunZiLiaoWeiHu from "../../components/ZhuYuan/XiTongWeiHu/ShouFeiBiaoZhunZiLiaoWeiHu";



import './ZhuYuan.css'
import { UploadOutlined, UserOutlined, BankOutlined, SettingOutlined, AccountBookOutlined, MailOutlined,PoweroffOutlined } from '@ant-design/icons';

const { Header, Content, Footer, Sider } = Layout;
const { SubMenu } = Menu;





const ZhuYuan = () => {
 let history = useHistory();
  const [key, setKey] = useState(['1'])
  // const [subKey, setSubKey] = useState(['sub1'])
   function confirm(e) {
    // console.log(e);
  
    sessionStorage.removeItem("isLogin")
    sessionStorage.removeItem("userInfo")
    history.push("/login")
    message.success('退出成功');
    
  }
  
  function cancel(e) {
    // console.log(e);
    message.error('取消退出登录');
  }
  useEffect(() => {
    setKey(sessionStorage.getItem("key") ? sessionStorage.getItem("key") : sessionStorage.setItem("key", ['1']))
    // setSubKey(sessionStorage.getItem("subKey") ? sessionStorage.getItem("subKey") : sessionStorage.setItem("subKey", ['sub1']))
  })


  return (
    <Layout className="box">
      <Sider
        breakpoint="lg"
        collapsedWidth="0"
        onBreakpoint={broken => {
          console.log(broken);
        }}
        onCollapse={(collapsed, type) => {
          console.log(collapsed, type);
        }}
      >
        <div className="logo" >住院部</div>
        <Menu theme="dark"
          mode="inline"
          selectedKeys={key}
          //defaultOpenKeys={['sub1']}
          // openKeys={subKey}
          onSelect={({ item, key, keyPath, selectedKeys, domEvent }) => { sessionStorage.setItem("key", key); setKey(key) }}
        // onOpenChange={(openKeys) => { sessionStorage.setItem("subKey", openKeys); setSubKey(openKeys) }}
        >
          <SubMenu key="sub1" icon={<UserOutlined />} title=" 入院管理">
            <Menu.Item key="1"><Link to="/zy/brryxx">病人入院信息</Link></Menu.Item>
          </SubMenu>
          <SubMenu key="sub2" icon={<BankOutlined />} title=" 病房管理">
            <Menu.Item key="2"><Link to="/zy/bfxx">病房信息</Link></Menu.Item>
          </SubMenu>
          <SubMenu key="sub3" icon={<UploadOutlined />} title=" 出院管理">
            <Menu.Item key="3"><Link to="/zy/cybrxx">出院病人信息</Link></Menu.Item>
          </SubMenu>
          <SubMenu key="sub4" icon={<AccountBookOutlined />} title=" 在院计费">
            <Menu.Item key="4"><Link to="/zy/kmbmb">科目编码表</Link></Menu.Item>
            <Menu.Item key="5"><Link to="/zy/sfbzcx">收费标准查询</Link></Menu.Item>
            <Menu.Item key="6"><Link to="/zy/grfymx">个人费用明细</Link></Menu.Item>
            <Menu.Item key="7"><Link to="/zy/zybsr">住院部收入</Link></Menu.Item>
            <Menu.Item key="8"><Link to="/zy/jfgl">缴费管理</Link></Menu.Item>
          </SubMenu>
          <SubMenu key="sub5" icon={<SettingOutlined />} title=" 入院系统维护管理">
            <Menu.Item key="9"><Link to="/zy/kmbmwh">科目编码维护</Link></Menu.Item>
            <Menu.Item key="10"><Link to="/zy/sfbzwh">收费标准资料维护</Link></Menu.Item>
            <Menu.Item key="11"><Link to="/zy/qlgqsj">清理过期数据</Link></Menu.Item>
          </SubMenu>
        </Menu>
      </Sider>
      <Layout >
        <Header className="site-layout-sub-header-background" style={{ padding: 0, fontSize: "20px", textAlign: "center" }} >
			 <Row justify="space-between" align="middle" >
            <Col span={1} offset={20}><Avatar size={34} icon={<UserOutlined />} /></Col>
            <Col spsn={1}>{JSON.parse(sessionStorage.getItem("userInfo")).username}</Col>
            <Col span={2}>
              <Popconfirm
              placement="leftTop"
                title="是否退出登录"
                onConfirm={confirm}
                onCancel={cancel}
                okText="是"
                cancelText="否"
              >
                <Button type="primary" icon={<PoweroffOutlined />}>退出登录</Button>
              </Popconfirm>
              </Col>
          </Row>
        </Header>
        <Content style={{ margin: '24px 0px 0 16px' }} className="Right">
<Switch>
          {/* 入院管理 */}
          <Route path="/zy/brryxx" component={BingRenRuYuanXinXi}></Route>
          <Route path="/zy/xzbr" component={XinZengBingRen}></Route>
          <Route path="/zy/psi" component={PersonInfo}></Route>
          {/* 病房管理 */}
          <Route path="/zy/bfxx" component={BingFangXinXi}></Route>
          <Route path="/zy/bingChuangXinXi" component={BingChuangXinXi}></Route>
          <Route path="/zy/xiugaibingchuang" component={XiuGaiBingChuang}></Route>
          <Route path="/zy/xiugaiyizhu" component={XiuGaiYiZhu}></Route>
          {/* 出院管理 */}
          <Route path="/zy/cybrxx" component={ChuYuanBingRenXinXi}></Route>
          <Route path="/zy/Chuyuanbingrenbingli" component={Chuyuanbingrenbingli}></Route>
          <Route path="/zy/ChuyuanJinemingxi" component={ChuyuanJinemingxi}></Route>
          {/* 在院计费 */}
          <Route path="/zy/kmbmb" component={KeMuBianMaBiao}></Route>
          <Route path="/zy/sfbzcx" component={ShouFeiBiaoZhun}></Route>
          <Route path="/zy/grfymx" component={GeRenFeiYong}></Route>
          <Route path="/zy/zybsr" component={ZhuYuanBuShouRu}></Route>
          <Route path="/zy/jfgl" component={JiaoFeiGuanLi}></Route>
          {/* 入院系统维护管理 */}
          <Route path="/zy/kmbmwh" component={KeMuBianMaBiaoWeiHu}></Route>
          <Route path="/zy/sfbzwh" component={ShouFeiBiaoZhunZiLiaoWeiHu}></Route>
          <Route path="/zy/qlgqsj" component={QingLiGuoQiShuJu}></Route>

			 <Redirect to="/zy/brryxx" exact from="/zy"></Redirect>
         </Switch>


        </Content>
        <Footer style={{ textAlign: 'center' }}>复旦五官科医院管理系统 ©2021</Footer>
      </Layout>
    </Layout>
  );
}

export default ZhuYuan;



